package com.haitaoit.chengquan.module.center.activity.info.update;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.haitaoit.chengquan.R;
import com.haitaoit.chengquan.base.BaseActivity;
import com.haitaoit.chengquan.module.center.model.UserInfoModel;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;

public class UpdatePhoneActivity extends BaseActivity {
    @ViewInject(R.id.phone_number)
    TextView phone_number;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView_V(R.layout.activity_update_phone);
        setTitle_V("手机修改");
        setLeftShow(1, R.mipmap.left);
        backLeft_V();
        ViewUtils.inject(this);

        String phone = UserInfoModel.getUser_info().getPhone().substring(0, 3) + "****" +
                UserInfoModel.getUser_info().getPhone().substring(UserInfoModel.getUser_info().getPhone().length() - 4,
                        UserInfoModel.getUser_info().getPhone().length());
        phone_number.setText(phone);

        // 广播 修改手机绑定成功
        IntentFilter mFilter = new IntentFilter();
        mFilter.addAction("updatephone_succ");
        registerReceiver(mReceiver, mFilter);
    }

    @OnClick({R.id.phone_next})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.phone_next:
                startActivity(new Intent(UpdatePhoneActivity.this, UpdatePhoneActivity2.class));
                break;
        }
        super.onClick(v);
    }

    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            finish();
        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mReceiver);
    }
}
